Methods
(static) tapMessage(message) → {function}
- Source:
- Since:
- 0.3.0
Return a function that prints a message and returns the input. This can be useful for example with saveObjPassthrough
Example
> doubleTriple = filepath => _.pipe([
mapWith(x => 3 * x),
saveObjPassthrough(filepath)
tapMessage(`Saved tripled items in ${someFilepath}`),
mapWith(x => 2 * x),
])
> fn = doubleTriple('foo/bar.json')
> fn([1, 2, 3])
[6, 12, 18]
Saved tripled items in foo/bar.json
Parameters:
Name | Type | Description |
---|---|---|
message |
string |
Returns:
- (Any -> Any) – @sideEffects: console.log
- Type
- function
(static) tapTime(label) → {function}
- Source:
- Since:
- 0.5.0
- See:
Return a function that starts a timer for the provided label and returns the
input.
To be used with tapTimeEnd
.
Example
> _.pipe([
tapTime('all'),
fn1,
fn2,
tapTime('fn3'),
fn3,
tapTimeEnd('fn3'),
tapTimeEnd('all'),
])
all: 2.35693359375 ms
fn3: 0.38475648398 ms
Parameters:
Name | Type | Description |
---|---|---|
label |
string |
Returns:
- (Any -> Any) - @sideEffects: console.log
- Type
- function
(static) tapTimeEnd(label) → {function}
- Source:
- Since:
- 0.5.0
- See:
Return a function that stops a timer for the provided label, logs the elapsed
time and returns the input.
To be used with tapTime
.
Example
> _.pipe([
tapTime('all'),
fn1,
fn2,
tapTime('fn3'),
fn3,
tapTimeEnd('fn3'),
tapTimeEnd('all'),
])
all: 2.35693359375 ms
fn3: 0.38475648398 ms
Parameters:
Name | Type | Description |
---|---|---|
label |
string |
Returns:
- (Any -> Any) - @sideEffects: console.log
- Type
- function
(static) tapType(label) → {function}
- Source:
- Since:
- 0.3.0
Return a function that prints the input type (preceded by the label, if provided) and returns the input.
Example
> size = _.pipe([
tapType(),
_.values,
tapType('values'),
_.getKey('length')
tapType('length'),
])
> size({a: 1, b: 2})
2
Object // logged
values: Array // logged
length: Number // logged
Parameters:
Name | Type | Description |
---|---|---|
label |
string |
Returns:
- (Any -> Any) – @sideEffects: console.log
- Type
- function
(static) tapTypeAndValue(label) → {function}
- Source:
- Since:
- 0.3.0
Return a function that prints the input type an the input (preceded by the label, if provided) and returns the input.
Example
> size = _.pipe([
tapTypeAndValue(),
_.values,
tapTypeAndValue('values'),
_.getKey('length')
tapTypeAndValue('length'),
])
> size({a: 1, b: 2})
2
Object {a: 1, b: 2} // logged
values: Array [1, 2] // logged
length: Number 2 // logged
Parameters:
Name | Type | Description |
---|---|---|
label |
string |
Returns:
- (Any -> Any) – @sideEffects: console.log
- Type
- function
(static) tapValue(label) → {function}
- Source:
- Since:
- 0.3.0
Return a function that prints the input (preceded by the label, if provided) and returns the input.
Example
> doubleTriple = _.pipe([
tapValue(),
mapWith(x => 2 * x),
tapValue('doubled'),
mapWith(x => 3 * x),
tapValue('tripled')
])
> doubleTriple([1,2,3])
[6, 12, 18]
[1, 2, 3] // logged
doubled: [2, 4, 6] // logged
tripled: [6, 12, 18] // logged
Parameters:
Name | Type | Description |
---|---|---|
label |
string |
Returns:
- (Any -> Any) – @sideEffects: console.log
- Type
- function